//
//  ViewController.swift
//  QuickyClosures
//
//  Created by lordpan on 05/26/2020.
//  Copyright (c) 2020 lordpan. All rights reserved.
//

import UIKit
import QuickyClosures


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let v = QuickyClosuresTest()
        self.view.addSubview(v)
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    let viewframe = CGRect.init(x: 10, y: 100, width: 150, height: 300)

    
    func QuickyClosuresTest() -> UIView  {
        
        let quick = UIView.init(frame: viewframe)
            .quick
            .backgroundColor_qk_s(UIColor.gray)
            .addSubview_qk_f(UILabel.init())>^
            .text_qk_s("这是一个label")
            .sizeToFit_qk_f()<^
            .addSubview_qk_f(UIButton.init())>^
            .frame_qk_s(CGRect.init(x: 20, y: 110, width: 110, height: 50))
            .setTitle_qk_f("这是一个button", for: .normal)
            .layer_qk_g()>^
            .cornerRadius_qk_s(6)
            .borderWidth_qk_s(2)
            .masksToBounds_qk_s(true)
            .quick<^
            .superview_qk_g().backgroundColor_qk_s(UIColor.green)
        return quick.root.value
        
        return UIView.init(frame: viewframe) .quick .backgroundColor_qk_s(UIColor.gray) .addSubview_qk_f(UILabel.init())>^ .text_qk_s("这是一个label") .sizeToFit_qk_f()<^ .addSubview_qk_f(UIButton.init())>^ .frame_qk_s(CGRect.init(x: 20, y: 110, width: 110, height: 50)) .setTitle_qk_f("这是一个button", for: .normal) .layer_qk_g()>^ .cornerRadius_qk_s(6) .borderWidth_qk_s(2) .masksToBounds_qk_s(true) .quick<^ .superview_qk_g().backgroundColor_qk_s(UIColor.green).root.value
        
    }
    func QuickyClosuresTest2() -> UIView  {
        
        return UIView.init(frame: viewframe)
            .quick
            .addSubview_qk_f( UILabel.init().quick.text_qk_s("这是一个label").sizeToFit_qk_f().value )
            .layer_qk_g()>^.cornerRadius_qk_s(6).borderWidth_qk_s(2).masksToBounds_qk_s(true)<^
            .value

        
    }
    func nouseQuickyClosuresTest() -> UIView  {
        let view =  UIView.init(frame: viewframe)
        let label = UILabel.init()
        view.addSubview(label)
        label.text = "这是一个label"
        label.sizeToFit()
        
        let button = UIButton.init()
        view.addSubview(button)
        button.frame = CGRect.init(x: 20, y: 110, width: 110, height: 50)
        button.setTitle("这是一个button", for: .normal)
        button.layer.cornerRadius = 6
        button.layer.borderWidth = 2
        button.layer.masksToBounds = true
        button.backgroundColor = UIColor.green
        
        return view
    }
    func nouseQuickyClosuresTest2() -> UIView  {
        let view =  UIView.init(frame: viewframe)
        let label = UILabel.init()
        label.text = "这是一个label"
        label.sizeToFit()
        view.addSubview(label)
        view.layer.cornerRadius = 6
        view.layer.borderWidth = 2
        view.layer.masksToBounds = true
        return view
       
    }
}



